<script type="text/javascript" src="<?php echo base_url(); ?>static/select2/select2.min.js" ></script>
<script type="text/javascript" src="<?php echo base_url(); ?>static/js/selectSearchGlobal.js"></script>

<script>
    function appGaSave() {
            $pJumlahI=$('#pJumlahI').val();
            var arrCek=[""];
            var arrWareItemId=[""];
            var x=0;
            for($x=0;$x<$pJumlahI;$x++){
                arrWareItemId[$x]=document.getElementById("pWareItemId"+$x).value;
                arrCek[$x]=document.getElementById("cek"+$x).value;
            }
            $.post("<?= site_url() ?>search_global/app_gaSave", {
                pCTab: $('#pCTab').val(),
                pCType: $('#pCType').val(),
                pCtrlID: $('#pCtrlID').val(),
                pApproval: $('#pApproval').val(),
                pNikRequestBy: $('#pNikRequestBy').val(),
                pComment: $('#pComment').val(),
                pCek: arrCek,
                pWareItemId: arrWareItemId
                //pAccesNo: $('#pAccesNo').val()
            }//,
            //function(data) {
            //    window.location = '<?php echo base_url(); ?>search_global';
            //}
            );
        }
    function cancel(){
        window.location = '<?php echo base_url(); ?>search_global';
    }
</script>


<?php
$this->load->model("sGlobal_model");
if(!empty($cRequestNo)){
    foreach($getDetail as $a){
        $rFloor 		= $a['ROOM_FLOOR'];
    	$rJenis 		= $a['ROOM_JENIS'];
    	$rType 			= $a['ROOM_TYPE'];
    	$rDate 			= $a['ROOM_DATE'];
    	$rStarHour 		= $a['STAR_HOUR'];
    	$rEndHour 		= $a['END_HOUR'];
    	$rDesc 			= $a['ROOM_DESCRIPTION'];
    	$rParicipant 	= $a['ROOM_PARTICIPANT'];
    	$rCondition 	= $a['ROOM_CONDITION'];
    	$rId 			= $a['ID'];
    	$rName 			= $a['NAME'];
    	$rOrg 			= $a['ORG'];
    	$rJob 			= $a['JOB_POSITION'];
    }
}
?>
<div id="top" >
	<form id="formarea" role="form" method="post" action="#" class="form-horizontal">
    <input type="hidden" value="<?php echo $cSikjId; ?>" id="cSikjId" />
    <input type="hidden" value="<?php echo $cRequestNo; ?>" id="pCtrlID" />
    <input type="hidden" value="<?php echo $cTab; ?>" id="pCTab" />
    <input type="hidden" value="<?php echo $cType; ?>" id="pCType" />
    <input type="hidden" value="<?php echo $rId;?>" id="pNikRequestBy" name="pNikRequestBy"/>
    
	<div class="col-md-offset-0">
		<div class="col-md-11">
            <div class="panel panel-default">
				<div class="panel-heading"><h4 class="panel-title"><b class="caret"></b><b> User Login</b></h4></div>
				<div class="panel-body">
                
					<div class="col-xs-12 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-3">NIK</label>
							<div class="col-md-7"><input type="text" value="<?php echo $sesNik;?>" id="pNik" class="select2 form-control input-sm" readonly=""/></div>
						</div>					
						<div class="form-group">
							<label class="control-label col-md-3">Nama</label>
							<div class="col-md-7"><input type="text" value="<?php echo $sesName;?>" class="form-control input-sm" readonly=""/></div>
						</div>
					</div>
                    
					<div class="col-sm-7 col-md-6">
						<!--<div class="form-group">
							<label class="control-label col-md-4">Departement</label>
							<div class="col-md-7"><input type="text" value="<?php echo $aOrg;?>" class="form-control input-sm" readonly=""/></div>
						</div>-->
						<div class="form-group">
							<label class="control-label col-md-4">Job Position</label>
							<div class="col-md-8"><input type="text" value="<?php echo $sesJob;?>" class="form-control input-sm" readonly=""/></div>
						</div>
					</div>
                    
				</div>
			</div>
            
			<div class="panel panel-default">
				<div class="panel-heading"><h4 class="panel-title"><b class="caret"></b><b> Requestor</b></h4></div>
				<div class="panel-body">
                
					<div class="col-xs-12 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-3">Nama</label>
							<div class="col-md-7">
                                <input type="text" id="r_nama" class="select2 form-control input-sm" value="<?php echo $rName;?>" readonly=""/>
                            </div>
						</div>					
						<div class="form-group">
							<label class="control-label col-md-3">ID</label>
							<div class="col-md-3"><input type="text" value="<?php echo $rId;?>" id="r_id" class="form-control input-sm" readonly=""/></div>
						</div><!--
						<div class="form-group">
                            <input type="hidden" id="r_mgrid" value="<?php echo $aSikAtasanNik;?>"/>
							<label class="control-label col-md-3">Nama Atasan</label>
							<div class="col-md-9"><input type="text" value="<?php echo $aSikAtasanName;?>" id="r_mgr" class="form-control input-sm" readonly=""/></div>
						</div>-->
					</div>
                    
					<div class="col-sm-7 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-4">Departement</label>
							<div class="col-md-7"><input type="text" value="<?php echo $rOrg;?>" id="r_dept" class="form-control input-sm" readonly=""/></div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-4">Job Position</label>
							<div class="col-md-8"><input type="text" value="<?php echo $rJob;?>" id="r_job" class="form-control input-sm" readonly=""/></div>
						</div>
					</div>
                    
				</div>
			</div>
			<div class="panel panel-default">
				<div class="panel-heading">
					<h4 class="panel-title"><b class="caret"></b><b> Request</b></h4>
				</div>
				<div class="panel-body">
					<div class="col-md-6">
						<div class="form-group">
							<label class="control-label col-md-2">Lantai</label>
							<div class="col-md-9">
                                <input id="pFloor" type="text" class="form-control input-sm" size="55" value="<?php echo $rFloor;?>" readonly=""/>
                            </div>              
						</div>
						<div class="form-group">
							<label class="control-label col-md-2">Type Ruang</label>
							<div class="col-md-4"><input id="pType" type="text" class="form-control input-sm" value="<?php echo $rType; ?>" size="30" readonly=""/></div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-2">Category Ruang</label>
							<div class="col-md-4"><input id="pCategory" type="text" class="form-control input-sm" value="<?php echo $rJenis;?>" size="30" readonly=""/></div>
						</div>
                        <div class="form-group">
							<label class="control-label col-md-2">Tanggal Pemakaian</label>
							<div class="col-md-9">
                                <input id="pRoomDate1" type="text" class="form-control input-sm" size="55" value="<?php echo $rDate;?>" readonly=""/>
                            </div>              
						</div>
						<div class="form-group">
							<label class="control-label col-md-2">Jam Pemakaian</label>
							<div class="col-md-4">
                                <input id="pStartHour" type="text" class="form-control input-sm" value="<?php echo $rStarHour; ?>" size="30" readonly=""/>                            
                            </div>
                            <div class="col-md-4">
                                <input id="pEndHour" type="text" class="form-control input-sm" value="<?php echo $rEndHour; ?>" size="30" readonly=""/>                            
                            </div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-2">Approval</label>
							<div class="col-md-4">
                            <select class="form-control input-form select2" id="pApproval" style="width:100%">
                                <option value="Y">Approve</option>
                                <option value="N" selected="">Disapprove</option>
        				    </select>
                            </div>
						</div>
                        <div class="form-group">
							<label class="control-label col-md-2">Comment</label>
							<div class="col-md-9">
                                <textarea class="form-control input-sm" id="pComment"></textarea>
                            </div>              
						</div>
					</div>
					<div class="col-md-6">
						<div class="form-group">
							<label class="control-label col-md-2">Participan</label>
							<div class="col-md-9"><input type="text" class="form-control input-sm" id="pParticipan" value="<?php echo $rParicipant;?>" readonly=""/> </div>
						</div>
                        <div class="form-group">
                            <label class="control-label col-md-2">Room Spec</label>
                            <div class="col-md-9"><input type="text" class="form-control input-sm" id="pCondition" value="<?php echo $rCondition;?>" readonly=""/></div>
						</div>
                        <div class="form-group">
                            <label class="control-label col-md-2">Agenda</label>
                            <div class="col-md-9"><textarea class="form-control input-sm" id="pDescription" readonly=""><?php echo $rDesc;?></textarea></div>
						</div>
					</div>
                    
                    
                    
					<div class="col-md-12 well well-sm" id="bawahForm">
						<div class="form-group">
							<div class="col-md-5"><label style="color:#003399">
                            </label></div>
						</div>
						<div class="form-group">
							<div class="col-md-12">
								<table class="table table-bordered table-condensed table-striped" style="margin-bottom:0px">
									<tbody>
										<tr>
											<th class="tblhead" style="width:20%;text-align:center">Approve</th>
											<th class="tblhead" style="width:10%;text-align:center">No</th>
											<th class="tblhead" style="width:30%;text-align:center">Item Name</th>
											<th class="tblhead" style="width:10%;text-align:center">Total Qty Reservation</th>										
											<th class="tblhead" style="width:30%;text-align:center">Total Available</th>										
										</tr>
                                    <?php
									   $i=0;
									   $no=1;
									       foreach ($getDetail2 as $a){
									            $aWareItemName  = $a["ROOMD_DESCRIPTION"];
        										$aWareItemQty   = $a['ROOMD_QTY'];
        										$aWareItemAvail = $a['WAREHOUSE_ITEM_QTY_IN'];
        										//$aWareItemId    = $a['ROOMD_ID']; //Room id=Ctrl ID, kenapa dipakai, seharusnya warehouse_id
                                                $aWareItemId    = $a['WAREHOUSE_ID']; //Room id=Ctrl ID, kenapa dipakai, seharusnya warehouse_id
        										$oddeven = $oddeven=='even'?'odd':'even';
                                               
									?>
										<tr>
                                            <input type="hidden" id="pWareItemId<?php echo $i; ?>" value="<?php echo $aWareItemId;?>"/>
											<td style="width:3%;">
                                                <select id="cek<?php echo $i; ?>" class="form-control input-sm">
                                                    <option value="N">Tidak</option>
                                                    <option value="Y">Ya</option>
                                                </select>
                                            </td>
											<td style="width:15%;"><?php echo $i+1; ?></td>
											<td style="width:20%;"><?php echo $aWareItemName; ?></td>
											<td style="width:7%;"><?php echo $aWareItemQty; ?></td>
											<td style="width:20%;text-align:center"><?php echo $aWareItemAvail; ?></td>																												
										</tr>
                                    <?php
    	                                   $i++;
    									   $no++;
									   }?>
                                       <input type="hidden" id="pJumlahI" value="<?php echo $i; ?>"/>
                                       
									</tbody>
								</table>
							</div>
						</div>
					</div>
                    
                    
					<div class="row"> 
                        <div class="col-sm-12">
                            <div class="form-group">
                                <label class="control-label col-md-3"></label>
        						<div class="col-sm-2">
                                    <button type="button" class="btn btn-primary btn-block" onclick="appGaSave();">Submit</button>
                                </div>
                                <div class="col-sm-2">
                                    <button type="button" class="btn btn-default btn-block" onclick="cancel();" >Cancel</button>
                                </div>
    				        </div>
                        </div>                   
                    </div>
				</div>
			</div>
		</div>
	</div>
	</form>
</div>